package top.xunfong.knowledge.controller;

import top.xunfong.common.core.domain.R;
import top.xunfong.common.core.domain.TableDataInfo;
import top.xunfong.common.core.domain.dto.BatchDTO;
import top.xunfong.knowledge.service.KnowledgeInfoService;
import top.xunfong.knowledge.dto.KnowledgeInfoDTO;
import top.xunfong.knowledge.dto.KnowledgeInfoQueryDTO;
import top.xunfong.knowledge.vo.KnowledgeInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.xunfong.mybatis.core.page.PageDTO;

@RestController
@RequestMapping("/knowledgeInfo")
public class KnowledgeInfoController {

    @Autowired
    private KnowledgeInfoService knowledgeInfoService;

    /**
     * 新增
     *
     * @param dto
     * @return
     */
    @PostMapping("/insert")
    public R<?> insertKnowledgeInfo(@RequestBody KnowledgeInfoDTO dto) {
        return knowledgeInfoService.insertKnowledgeInfo(dto);
    }


    /**
     * 修改
     *
     * @param dto
     * @return
     */
    @PostMapping("/update")
    public R<?> updateKnowledgeInfo(@RequestBody KnowledgeInfoDTO dto) {
        return knowledgeInfoService.updateKnowledgeInfo(dto);
    }

    /**
     * 批量删除
     *
     * @param dto
     * @return
     */
    @PostMapping("/delete")
    public R<?> deleteKnowledgeInfo(@RequestBody BatchDTO<Long> dto) {
        return knowledgeInfoService.deleteKnowledgeInfo(dto);
    }

    /**
     * 列表查询
     *
     * @param dto
     * @return
     */
    @PostMapping("/list")
    public TableDataInfo<KnowledgeInfoVO> listKnowledgeInfo(@RequestBody KnowledgeInfoQueryDTO dto, PageDTO pageDTO) {
        return knowledgeInfoService.listKnowledgeInfo(dto, pageDTO);
    }

    @GetMapping("/single")
    public R<KnowledgeInfoVO> singleKnowledgeInfo(Long id) {
        return knowledgeInfoService.singleKnowledgeInfo(id);
    }
}